
#include "main.h"
#include "lvgl_project.h"

void app_main()
{
	// char *buf =(char*)heap_caps_malloc(1024*1, MALLOC_CAP_SPIRAM);
	// if(buf==NULL)
	// {
	// 	main_debug("内存申请失败\r\n");
	// }

	main_debug("-------------开始运行----------------\r\n");
	main_debug("esp32 sdk version :%s\n", esp_get_idf_version());

	bsp_key_init();
	bsp_power_init();
    my_spiffs_init();

	bsp_sd_init();
	bsp_ledc_init();

	//multi_button_task_init();

	nvs_init();
	system_init();

	//font_init();

	i2c2_init();
	cst816t_init();
    lcd_init(SPI3_HOST, 80000000);

    lvgl_init();
	lv_port_fs_init();
	lvgl_YangShi_create();
    lvgl_desktop_create(lv_scr_act());

	wifi_init();

    //lvgl_clock_create(lv_scr_act());

	//lv_demo_stress();
	//lv_demo_printer();
	//lv_demo_music();
	//lv_demo_widgets();


	bsp_ledc_set_duty(5);
	bsp_power_on();
	//lvgl_hint_create(lv_scr_act(),"欢迎使用",200,5);

	//multi_button_callback_init();
	main_debug("初始化结束");

	// while (1)
	// {
	// 	printf_memory();
	// 	vTaskDelay(5000 / portTICK_PERIOD_MS);
	// }
    // while (1) {
    // //    main_debug("DRAM : [%6d] | PSRAM : [%7d]\r\n",
    // //         heap_caps_get_free_size(MALLOC_CAP_INTERNAL),
    // //         heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
    //     vTaskDelay(pdMS_TO_TICKS(2000));
    // }
}
void ptintf_memory(char *file,int len)
{
    int free_size;

    ESP_LOGW("内存监控", "%s:%d",file,len);
    free_size = heap_caps_get_free_size(MALLOC_CAP_INTERNAL);
    printf("内部RAM剩余%d.%dKB  ", free_size/1024,free_size%1024);
    free_size = heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
    printf("外部PSRAM剩余%d.%dkB\r\n",free_size/1024,free_size%1024);
}
